/**********************************************************

@description:
*File Name:queue.c
*Author: ydx
*mail: yudongxiang93@163.com
*Create Time: Wed 07 May 2025 07:21:33 AM CST
**********************************************************/
#include<stdio.h>
#include<stdlib.h>
#include "queue.h"
queue * init_queue(){
	queue *q=(queue*)malloc(sizeof(queue));
	q->front=q->rear=0;
	return q;
}
int isFull(queue *q){
	return (q->rear+1)%MAXSIZE==q->front;
}
int isEmpty(queue *q){
	return q->rear==q->front;
}
void enqueue(queue *q,int data){
	if(isFull(q)){
		printf("isFull\n");
		return;
	}
	q->data[q->rear]=data;
	q->rear=(q->rear+1)%MAXSIZE;
}
int dequeue(queue *q){
	if(isEmpty(q)){
		printf("isEmpty\n");
		return -1;
	}
	int tmp=q->data[q->front];
	q->front=(q->front+1)%MAXSIZE;
	return tmp;
}
